!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-model操作其他表单元素</title>
    <style>
        [v-cloak] {
            display: none;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        div {
            width: 300px;
            height: 40px;
            margin: 100px auto;
            background: #000;
            border-radius: 20px;
            padding: 5px;
        }

        div>p {
            position: relative;
            width: 30%;
            height: 100%;
            background: rgb(11, 154, 210);
            border-radius: 15px;
            transition: all .6s;
            margin-bottom: 50px;
        }

        p>span {
            position: absolute;
            right: -30px;
            bottom: -30px;
        }
    </style>
</head>

<body>
    <form action="javascript:void(0)" method="post" autocomplete="off">
        <h4>学习v-model 绑定其他表单元素</h4>
        <section>
            <span>姓名：</span><input type="text" name="username" id="" v-model.trim="username">
        </section>
        <section>
            <span>是否单身：</span><input type="checkbox" name="single" id="" v-model.number="single">
        </section>
        <section>
            <span>性别：</span><input type="radio" name="gender" id="male" value="1" v-model.number="gender">男
            <input type="radio" name="gender" id="famale" value="2" v-model.number="gender">女
        </section>
        <section>
            <span>城市：</span>
            <select name="city" v-model.number="city">
                <option value="1">北京</option>
                <option value="2">上海</option>
                <option value="3">广州</option>
                <option value="4">重庆</option>
            </select>
        </section>
        <section>
            <span>自我介绍：</span><textarea name="intro" id="" v-model.trim="intro"></textarea>
        </section>
        <button @click="registry">立即注册</button>
    </form>

    <script src="./js/dev/vue.js"></script>
    <script>
        const app = new Vue({
            el: 'form',
            data: {
                username: '',
                single: 0,
                gender: 0,
                city: 0,
                intro: '',
            },
            methods: {
                registry() {
                    console.log(`username = ${this.username},single = ${this.single},gender = ${this.gender},city = ${this.city},intro = ${this.intro},`);
                }
            }
        })
    </script>
</body>

</html>